package com.ytjj.qmyx.admin.service.impl;

import com.github.pagehelper.PageHelper;
import com.ytjj.common.api.CommonPage;
import com.ytjj.qmyx.admin.dao.LiveDao;
import com.ytjj.qmyx.admin.model.request.LiveRequest;
import com.ytjj.qmyx.admin.service.LiveService;
import com.ytjj.qmyx.mall.model.Live;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class LiveServiceImpl implements LiveService {

    @Autowired
    private LiveDao liveDao;

    @Override
    public CommonPage<Live> getLiveList(LiveRequest liveRequest) {
        PageHelper.startPage(liveRequest.getPageNum(), liveRequest.getPageSize());
        List<Live> pageList = liveDao.selectList(liveRequest);
        return CommonPage.restPage(pageList);
    }

    @Override
    public int insertLive(LiveRequest liveRequest) {
        liveRequest.setCreateTime(new Date());
        return liveDao.insertLive(liveRequest);
    }

    @Override
    public int updateLive(LiveRequest liveRequest) {
        return liveDao.updateLive(liveRequest);
    }

    @Override
    public int isRecommend(Integer id, Integer isRecommend) {
        return liveDao.isRecommend(id, isRecommend);
    }

}
